﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace ExceptionService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ExceptionHandler : System.Web.Services.WebService
    {

        [WebMethod]
        public void HandleException(string version, string message, string source, string stack, string target, string curdir, string machine, string osversion, string proccount, string userdomainname, string userinteractive, string username, string netversion, string workingset)
        {
            SqlConnection con=new SqlConnection(Properties.Settings.Default.DBConn);
            con.Open();
            SqlCommand cmd=new SqlCommand("AddException",con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@date",SqlDbType.DateTime).Value=DateTime.Now;
            cmd.Parameters.Add("@message", SqlDbType.Text).Value = message;
            cmd.Parameters.Add("@version", SqlDbType.Text).Value = version;
            cmd.Parameters.Add("@source", SqlDbType.Text).Value = source;
            cmd.Parameters.Add("@stack", SqlDbType.Text).Value = stack;
            cmd.Parameters.Add("@target", SqlDbType.Text).Value = target;
            cmd.Parameters.Add("@curdir", SqlDbType.Text).Value = curdir;
            cmd.Parameters.Add("@machine", SqlDbType.Text).Value = machine;
            cmd.Parameters.Add("@osversion", SqlDbType.Text).Value = osversion;
            cmd.Parameters.Add("@proccount", SqlDbType.Text).Value = proccount;
            cmd.Parameters.Add("@userdomainname", SqlDbType.Text).Value = userdomainname;
            cmd.Parameters.Add("@userinteractive", SqlDbType.Text).Value = userinteractive;
            cmd.Parameters.Add("@username", SqlDbType.Text).Value = username;
            cmd.Parameters.Add("@netversion", SqlDbType.Text).Value = netversion;
            cmd.Parameters.Add("@workingset", SqlDbType.Text).Value = workingset;
            cmd.ExecuteNonQuery();
        }

        private void InitializeComponent()
        {

        }
    }
}
